package com.liangtian.mdm.base.utils;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>Encoding    :  UTF-8</p>
 * <p>Package Name: com.liangtian.mdm.base.utils </p>
 * <p>Project Name: dm </p>
 * <p>Copyright   :  Copyright(c) 2016 石化盈科信息技术有限责任公司 </p>
 * <p>Created Time: 2016-06-15 14:56</p>
 * <p>Description : 获取浏览器类型</p>
 *
 * @author : beamzhang
 * @version :  1.0
 */
public class BrowserUtils {

    public static String getBrowserName(HttpServletRequest request) {
        String agent = request.getHeader("User-Agent").toLowerCase();
        if (agent.indexOf("msie 7") > 0) {
            return "IE7";
        } else if (agent.indexOf("msie 8") > 0) {
            return "IE8";
        } else if (agent.indexOf("msie 9") > 0) {
            return "IE9";
        } else if (agent.indexOf("msie 10") > 0) {
            return "IE10";
        } else if (agent.indexOf("msie") > 0) {
            return "IE";
        } else if (agent.indexOf("opera") > 0) {
            return "Opera";
        } else if (agent.indexOf("firefox") > 0) {
            return "Firefox";
        } else if (agent.indexOf("webkit") > 0) {
            return "Chrome";
        } else if (agent.indexOf("gecko") > 0 && agent.indexOf("rv:11") > 0) {
            return "IE11";
        } else {
            return "Others";
        }
    }
}
